<?php

/*
require '../dbconnect.php';

$query = "SELECT amount FROM paymentplan WHERE id='5'";
$result = mysql_query($query);
$amount = mysql_result($result, 0);

echo $rida;

*/

?>

<html>
<head>
<script type="text/javascript">
function test(){
	var method = document.getElementById('method');
	//return method.value;
	alert(method.value);
}
             
</script>


</head>
<body>

<?php 
/*
	require '../dbconnect.php';

	$month = date('m');
	$year  = date('Y');
	$test_date_start = $year."-".$month."-"."01";
	$test_date_end = $year."-".$month."-"."31";
	
	$date_check_query = "SELECT * FROM payment WHERE date_created >=\"".$test_date_start."\" AND date_created <=\"".$test_date_end."\"";
	echo $date_check_query."<br />";
	
	if($row = mysql_fetch_array(mysql_query($date_check_query))){
		echo "works";
	}
	else {
		echo "error";
	}
*/	
?>

<?php 	
				require '../dbconnect.php';
				$paymentQuery = "SELECT * FROM payment JOIN paymentplan ON payment.paymentplan_id=paymentplan.id WHERE student_id=\"22\" AND datepaid=\"0000-00-00\"";
				$paymentResult = mysql_query($paymentQuery);	
				
			
				echo '<table id="payment" border="1">
					<thead>
						<td>Name</td>
						<td>Due date</td>
						<td>Amount</td>
						<td>Amount paid</td>
						<td>Method</td>
						<td>Pay</td>
						
					</thead>';

				echo "Payments"; 	
				while ($row = mysql_fetch_array($paymentResult)){
						echo "<tr>";
						echo "<td>".$row['name']."</td>";
						echo "<td>".$row['due_date']."</td>";
						echo "<td>".$row['amount']."</td>";
						echo "<td>".$row['amount_paid']."</td>";
						echo '<form action="paystuff.php" method="post">';
						echo "<td>". //onchange=\"test()
							"<select id=\"method\" name=\"method\">
							<option>Cash</option>
							<option>Card</option>
							<option>Wire</option>
							<option>Check</option>
							</select>".
							"</td>"; //$row['id']
						echo '<input type="hidden" name="id" value="'.$row['id'].'">';
						//echo "<td>"."<a href=\"paystuff.php?id="."onclick=\"test()\""."\">Pay</a>";
						//$method = "card";
						//echo "<td>"."<a href=\"paystuff.php?id=5&method= \">Pay</a>";
						echo '<td><input type="submit" value="pay"></td>';
						echo '</form>';
						echo "</tr>";				
					
				}	
				
				echo "</table>";
				
?>






































</body>
</html>